<!DOCTYPE html>
<html>

	<head>
		<meta http-equiv="Access-Control-Allow-Origin" content="*">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
		<script src="../js/flexible.debug.js"></script>
		<script src="../js/flexible_css.debug.js"></script>
		<link rel="stylesheet" type="text/css" href="../css/location.css"/>

	</head>

	<body>

		<div class="address">
				<div id="r-result">
					<span class="to"><img src="../img/adinw.png"/></span>
					<input type="text" id="suggestId" placeholder="请输入大厦名称或者小区名称" />
					<p id="Map_btn"><button class="Map_btn_c">确认</button></p>
				</div>
				<!--<div id="alert_map" style="height: 60px; background: red;"></div>-->
				<div id="l-map"></div>
			</div>
		<!--地图展示完-->

	</body>

</html>
<script src="../js/jquery-3.2.1.js"></script>
<script type="text/javascript" src='../js/mock.js'></script>
		<script type="text/javascript" src='../js/mockjs.js'></script>
<script type="text/javascript" src="http://api.map.baidu.com/getscript?v=2.0&ak=tIqExiZw1IyBNAshjMWI1PT1DtIhOsuc&services=&t=20170823191629"></script>
<script src="../js/bmap.js"></script>
<script type="text/javascript">
	//获取那个地图
		var getItem = localStorage.getItem('obj_list')
		   localStorage.setItem('action',getItem );
		   var defalute = localStorage.getItem('city_code');
		   localStorage.setItem('dafe_code',defalute)
		  defalute = JSON.parse(defalute)
		  var SHop =  localStorage.getItem('SHOPCODE');
		  localStorage.setItem('repetition',SHop);
		  console.log(defalute,SHop);
		  
		  
		  
		  
		  
		  
	var maptool = MapTool();
	maptool.getLocalCity(function(ops) {
		var city = ops.name;
		maptool.setOps({
			city: ops.name,
			addr: null,
			point: null,
			level: 16
		});
		maptool.init("l-map", function(data) {
			console.log(data)
			var point = data.point;
			var mark = maptool.addMarker(point.lng, point.lat);
			
			maptool.autoComplete("suggestId", function(ops, addr, short_addr) {
				mark.rem();
				maptool.getPoint(city, addr, function(point) {
					mark = maptool.addMarker(point.lng, point.lat);
					maptool.panTo(point);
					//maptool.panTo(point);
						lng = point.lng;
						lat = point.lat;
						const x = {
							x:lng,
							y:lat
						}
						localStorage.setItem('yymm_dd',JSON.stringify(x))
				})
//				alert(addr);
//				alert(short_addr);
			});
		});
	});
	$(function(){
	//点击确定按钮把值传到input
				$('#Map_btn').click(function(e) {
					var this_value = $('#suggestId').val();
					$('#location').val(this_value);
					localStorage.setItem('this_value',this_value)
					//$('#suggestId').val("");
						//所在地不能为空
						
					if (this_value === '') {
						alert('请您按照下列提示信息输入地址！')
						return false;
					}else{
						location.href = './address.html';
					}
				})
	})
</script>